<template>
    <div class="container">
        <MedicalInPrintListView ref="MedicalInPrintListView" />
        <addStockInView ref="addStockInView" />
        <div class="main">
            <div class="header felx">
                <div class="serachBox flex">
                    <div class="flex">
                        <p style="width: 60px;">入库单</p>
                    </div>
                    <input type="text" v-model="searchValue">
                    <button class="search" @click="getMylist">搜索</button>
                </div>
                <!-- <div class="serachBox flex">
                    <el-dropdown @command="selectHandle">
                        <div class="flex">
                            <p style="width: 60px;">{{ searchTitle }}</p> <el-icon>
                                <ArrowDown />
                            </el-icon>
                        </div>
                        <template #dropdown>
                            <el-dropdown-menu>
                                <el-dropdown-item command="入库单">入库单</el-dropdown-item>
                                <el-dropdown-item command="批次号">批次号</el-dropdown-item>
                            </el-dropdown-menu>
                        </template>
</el-dropdown>
<input type="text" v-model="searchValue" @keyup.enter="searchEnter">
<button class="search" @click="getMylist">搜索</button>
</div> -->

                <div class="addbtn flex" @click="goStockIn">
                    <p>新增入库单</p>
                </div>
            </div>
            <div class="borderBox">
                <div class="table_box">
                    <el-table :data="list" border style="width: 100%;" scrollTo :row-class-name="tableRowClassName"
                        :header-cell-style="headerCellStyle" :row-style="tableRowStyle"
                        @selection-change="handleSelectionChange">
                        <el-table-column type="index" label="序号" width="55" />
                        <!-- <el-table-column type="selection" :selectable="selectable" width="55" /> -->
                        <el-table-column prop="receiptCode" label="入库单" min-width="90">
                            <template #header>
                                <div class="header_icon">
                                    <span>入库单</span>
                                    <el-icon class="rotate">
                                        <MoreFilled />
                                    </el-icon>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="title" label="入库标题" min-width="100">
                            <template #header>
                                <div class="header_icon">
                                    <span>入库标题</span>
                                    <el-icon class="rotate">
                                        <MoreFilled />
                                    </el-icon>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="totalQuantity" label="入库数量" min-width="100">
                            <template #header>
                                <div class="header_icon">
                                    <span>入库数量</span>
                                    <el-icon class="rotate">
                                        <MoreFilled />
                                    </el-icon>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="totalValue" label="金额" min-width="90">
                            <template #header>
                                <div class="header_icon">
                                    <span>金额</span>
                                    <el-icon class="rotate">
                                        <MoreFilled />
                                    </el-icon>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="remark" label="备注" min-width="90">
                            <template #header>
                                <div class="header_icon">
                                    <span>备注</span>
                                    <el-icon class="rotate">
                                        <MoreFilled />
                                    </el-icon>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="supplier" label="供应商" min-width="90">
                            <template #header>
                                <div class="header_icon">
                                    <span>供应商</span>
                                    <el-icon class="rotate">
                                        <MoreFilled />
                                    </el-icon>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="createdBy" label="经办人" min-width="90">
                            <template #header>
                                <div class="header_icon">
                                    <span>经办人</span>
                                    <el-icon class="rotate">
                                        <MoreFilled />
                                    </el-icon>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="createdAt" label="入库时间" min-width="100">
                            <template #header>
                                <div class="header_icon">
                                    <span>入库时间</span>
                                    <el-icon class="rotate">
                                        <MoreFilled />
                                    </el-icon>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" width="110">
                            <template #default="scope">
                                <!-- <el-button type="primary"
                                    style="padding: 0 10px;background-color: #6F72FF;border: none;"
                                    @click="viewDetails(scope.row)">编辑</el-button> -->
                                <el-button type="primary"
                                    style="padding: 0 10px;background-color: #6F72FF;border: none;"
                                    @click="viewDetails(scope.row)">查看明细</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>

                <el-config-provider :locale="locale">
                    <div style="margin-top: 10px" class="pageBox flex">
                        <el-pagination :total="total" :current-page="page" :page-size="pageSize" background
                            layout="prev, pager, next, sizes" :page-sizes="[5, 10, 20, 30, 40, 50, 100]"
                            @size-change="changePageSize" @current-change="changeCurrentPage" />
                        <div class="flex">
                            <p>第 {{ page }} 条</p>
                            <p>共 {{ total }} 条数据</p>
                        </div>
                    </div>
                </el-config-provider>
            </div>
        </div>
    </div>
</template>
<script>
import { httpService } from "@/utils/httpService";
import { ElConfigProvider, ElMessage, ElLoading } from "element-plus";
import { MoreFilled, ArrowDown } from "@element-plus/icons-vue";
import zhCn from "element-plus/lib/locale/lang/zh-cn";
import { formatTime1 } from "@/utils/dateFormat"
import MedicalInPrintListView from "../../components/medicalProduct/MedicalInPrintListView.vue"
import addStockInView from "../../components/medicalProduct/addStockInView.vue"

export default {
    name: "MedicalProductLogin",
    components: { ElMessage, ElLoading, MoreFilled, ArrowDown, ElConfigProvider, MedicalInPrintListView, addStockInView },
    data() {
        return {
            page: 1,
            pageSize: 10,
            total: 0,
            list: [],
            requestor: "",
            materialName: "",
            searchTitle: "搜索条件",
            searchValue: "",
        };
    },
    setup() {
        return {
            locale: zhCn,
        };
    },
    computed: {},
    mounted() {
        this.getMylist()

    },
    methods: {
        handleSelectionChange(val) {
            this.printList = val
        },

        goStockIn() {
            this.$refs.addStockInView.flag = true
            this.$refs.addStockInView.getMaterialList()
            this.$refs.addStockInView.getNumberId()
        },

        tableRowClassName({ row, rowIndex }) {
            return rowIndex % 2 === 1 ? 'warning-row' : '';
        },
        headerCellStyle() {
            return {
                background: '#f2f2f2',
            };
        },
        tableRowStyle({ row, rowIndex }) {
            if (rowIndex % 2 === 1) {
                return {
                    background: '#F5F5F5',
                };
            }
        },
        selectHandle(value) {
            console.log(value);
            this.searchTitle = value
        },
        changePageSize(size) {
            this.pageSize = size;
            this.getMylist()
        },
        changeCurrentPage(page) {
            this.page = page;
            this.getMylist()
        },
        exportExcel() {
            this.fullscreenLoading = true
            httpService(
                "/javaApi/stockOut/exportExcel", {}, "get"
            ).then((data) => {
                this.fullscreenLoading = false
                window.open(data.message, "_blank")
            });
        },

        getMylist() {
         

            httpService(`/javaApi/stockInReceipt/list/${this.page}/${this.pageSize}`, { receiptCode: this.searchValue }, "get").then(
                (data) => {
                    if (data.list) {
                        data.list.map(item => item.createdAt = formatTime1(new Date(item.createdAt)))
                        this.list = data.list
                        this.total = data.total
                    }
                }
            );
        },
        viewDetails(data) {
            this.$refs.MedicalInPrintListView.flag = true
            this.$refs.MedicalInPrintListView.form = data
            this.$refs.MedicalInPrintListView.queryById(data.id)
        },


    },
};

</script>
<style scoped>
* {
    padding: 0;
    margin: 0;
}

.flex {
    display: flex;
    align-items: center;
}

.container {
    width: calc(100vw - 30px);
    height: calc(100vh - 30px);
    padding: 15px;
    background-color: #EEF7FB;
}

.main {
    width: calc(100% - 30px);
    height: calc(100% - 30px);
    background-color: #fff;
    border-radius: 10px;
    padding: 15px;
}

.header {
    height: 45px;
    display: flex;
    align-items: center;
}





.borderBox {
    height: calc(100% - 60px);
    border: 1px solid #DFDFDF;
    border-radius: 5px;
    box-sizing: border-box;
    margin-top: 15px;
}

.table_box {
    width: calc(100vw - 283px);
    height: calc(100% - 53px);
    overflow-y: auto;
}

.rotate {
    transform: rotate(90deg);
}



.header_btn {
    width: 99px;
    height: 32px;
    background-color: #6F72FF;
    border-radius: 5px;
    justify-content: center;
    font-size: 14px;
    color: #fff;
    margin-right: 15px;
    cursor: pointer;
}

.header_btn img {
    width: 17px;
    height: 18px;
    margin-right: 5px;
}

.serachBox {
    color: #666666;
    font-size: 14px;
    width: 353px;
    height: 36px;
    border: 1px solid #D0D0D0;
    box-sizing: border-box;
    border-radius: 20px;
    margin-right: 15px;
}

.serachBox .flex {
    justify-content: center;
    border-right: 1px solid #D0D0D0;
    margin-right: 10px;
    padding: 0 5px 0 15px;
    color: #666666;
    cursor: pointer;
}

.serachBox input {
    height: calc(100% - 4px);
    border: none;
    flex: 1;
    margin-right: 15px;
    outline: none;
}

.search {
    width: 59px;
    height: 30px;
    border-radius: 15px;
    border: none;
    background-color: #6F72FF;
    color: #fff;
    font-size: 14px;
    margin-right: 2px;
    outline: none;
}


.borderBox {
    height: calc(100% - 60px);
    border: 1px solid #DFDFDF;
    border-radius: 5px;
    box-sizing: border-box;
    margin-top: 15px;
}

.borderTop {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.workList {
    display: flex;
}

.workList p {
    color: #666;
    font-size: 14px;
    margin-left: 20px;
}

.workList p span {
    color: #6F72FF;
}

.borderTop .flex {
    margin-right: 20px;
}

.borderTop_btn {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #666666;
    margin-left: 40px;
    cursor: pointer;
}

.header_icon {
    display: flex;
    align-items: center;
    justify-content: space-between;
}



.rotate {
    transform: rotate(90deg);
}


.el-scrollbar__bar {
    z-index: 11;
    overflow-x: hidden;
    position: sticky;
}

.el-table.el-table--border {
    overflow: unset;
}


.pageBox {
    background-color: #f6f6f6;
    padding: 5px 0;
    border-top: 1px solid #e7e7e7;
    border-radius: 0 0 5px 5px;
}

.el-pagination {
    margin-left: 10px;
}

.pageBox {
    justify-content: space-between;
}

.pageBox .flex {
    color: #666;
    font-size: 14px;
    margin-right: 10px;
}

.pageBox .flex p {
    color: #666;
    font-size: 14px;
    margin-right: 20px;
}

.addbtn {
    width: 110px;
    height: 32px;
    border-radius: 5px;
    border: none;
    background-color: #6F72FF;
    color: #fff;
    font-size: 14px;
    margin-left: 15px;
    cursor: pointer;
    outline: none;
    line-height: 1;
    justify-content: center;
    margin-right: 15px;
}

.el-tooltip__trigger:focus-visible {
    outline: unset;
}
</style>